package Guo.guowantong.springsecurity_04.service.impl;

import Guo.guowantong.springsecurity_04.dao.SysPermissionRoleDao;
import Guo.guowantong.springsecurity_04.entity.SysPermissionRole;
import Guo.guowantong.springsecurity_04.service.SysPermissionRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 权限角色表(SysPermissionRole)表服务实现类
 *
 * makejava
 * 2021-06-17 17:30:26
 */
("sysPermissionRoleService")
public class SysPermissionRoleServiceImpl implements SysPermissionRoleService {
    private SysPermissionRoleDao sysPermissionRoleDao;

    /**
     * 通过ID查询单条数据
     *
     * id 主键
     * 实例对象
     */
    public SysPermissionRole queryById(Long id) {
        return this.sysPermissionRoleDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * offset 查询起始位置
     * limit 查询条数
     * 对象列表
     */
    public List<SysPermissionRole> queryAllByLimit(int offset, int limit) {
        return this.sysPermissionRoleDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param sysPermissionRole 实例对象
     * @return 实例对象
     */
    public SysPermissionRole insert(SysPermissionRole sysPermissionRole) {
        this.sysPermissionRoleDao.insert(sysPermissionRole);
        return sysPermissionRole;
    }

    /**
     * 修改数据
     *
     * sysPermissionRole 实例对象
     * 实例对象
     */
    public SysPermissionRole update(SysPermissionRole sysPermissionRole) {
        this.sysPermissionRoleDao.update(sysPermissionRole);
        return this.queryById(sysPermissionRole.getId());
    }

    /**
     * 通过主键删除数据
     *
     * id 主键
     * 是否成功
     */
    public boolean deleteById(Long id) {
        return this.sysPermissionRoleDao.deleteById(id) > 0;
    }
}